package com.sailfish.springbootdemo.dao.db1;

import com.sailfish.springbootdemo.common.DB1TableName;
import com.sailfish.springbootdemo.pojo.db1.BisLine;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

public interface BisLineDao {

    /**
     * 根据线体id + key 查询
     *
     * @param lineId
     * @return
     */
    @Results(id = "bisLineResultMap", value = {
            @Result(column = "bis_line_id", property = "bisLineId", jdbcType = JdbcType.INTEGER),
            @Result(column = "bis_key", property = "bisKey", jdbcType = JdbcType.VARCHAR),
            @Result(column = "reach_standard", property = "reachStandard", jdbcType = JdbcType.VARCHAR),
            @Result(column = "sys_pass_yield", property = "sysPassYield", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "update_time", property = "updateTime", jdbcType = JdbcType.DATETIMEOFFSET),
            @Result(column = "sort", property = "sort", jdbcType = JdbcType.INTEGER),
            @Result(column = "line_id", property = "lineId", jdbcType = JdbcType.INTEGER),
            @Result(column = "is_ok", property = "isOk", jdbcType = JdbcType.INTEGER),
    })
    @Select("select * from " + DB1TableName.BIS_LINE + " where line_id = #{lineId} and bis_key = #{bisKey}")
    BisLine getBisLineByLineAndKey(@Param("lineId") Integer lineId, @Param("bisKey") String bisKey);

    /**
     * 根据线体id删除
     *
     * @param lineId
     * @return
     */
    @Delete("delete from " + DB1TableName.BIS_LINE + " where line_id = #{lineId}")
    Integer deleteBisLineByLine(@Param("lineId") Integer lineId);

    /**
     * 插入
     *
     * @param bisLine
     * @return
     */
    @Insert("insert into " + DB1TableName.BIS_LINE + " (bis_key,reach_standard,sys_pass_yield,line_id,create_time,sort,is_ok) values " +
            "(#{bisLine.bisKey},#{bisLine.reachStandard},#{bisLine.sysPassYield},#{bisLine.lineId},#{bisLine.createTime},#{bisLine.sort},#{bisLine.isOk})")
    Integer addBisLine(@Param("bisLine") BisLine bisLine);
}
